# !/usr/bin/env python
# -*- coding:utf-8 -*-
# project name: CP_Automation
# author: "SongFang" 
# creation time: 2018/7/3 23:52
# Email: geg726@163.com

import unittest
from Operation.element import Element
from selenium.webdriver.common.keys import Keys
import time

el = Element()

class Test(unittest.TestCase):
    """火狐浏览器H5测试"""

    @classmethod
    def setUpClass(cls):
        # cls.driver = el.driver()
        cls.driver = el.Driver()

    def test01(self):
        el.openurl("http://192.168.1.191/mayi-h5/index.html#/home/my")
        el.xpath("//span[text()='点击登录']").send_keys(Keys.F12)
        el.xpath("//span[text()='点击登录']").send_keys(Keys.CONTROL, Keys.SHIFT, 'm')
        el.xpath("//span[text()='点击登录']").click()
        el.xpath('//*[@id="app"]/div/div/content/div[2]/div[1]/input').send_keys('pc001')
        el.xpath('//*[@id="app"]/div/div/content/div[2]/div[2]/input').send_keys('123456')

        el.xpath('//*[@id="app"]/div/div/content/div[2]/div[3]').click()


        self.assertTrue(el.trywait_assert_xpath("//span[text()='投注记录']"), "登录失败")
        # el.xpath("/html//div[@id='app']//a[@href='#/home']/span[.='首页']").click()

    def test02(self):
        """北京赛车整合投注大，10元"""
        el.css('.footer-nav li:nth-of-type(1) span').click()
        time.sleep(1)
        el.xpath("/html//div[@id='app']/div[@class='container']//h4[.='北京赛车']").click()
        try:
            el.xpath("/html//div[@id='app']/div//img[@src='images/03096d79.bet10@3x.png']").click()
        except:
            # el.text("本期已封盘")
            time.sleep(4)
            el.xpath("/html//div[@id='app']/div//img[@src='images/03096d79.bet10@3x.png']").click()
        el.test_get('.qishu','.reClock:nth-of-type(5)')
        el.xpath('//*[@id="app"]/div/div[2]/div[3]/div[2]/div[1]/div/div[1]/div').click()
        time.sleep(1)
        el.xpath("/html//div[@id='app']/div//div[.='投注']").click()

        time.sleep(10)
        self.assertFalse(el.trywait_assert_xpath("//id[text()='am-modal-container-1530689664047']"), '投注失败')
    #
    # def test03(self):
    #     """北京赛车冠亚军和投注7，10元"""





    @classmethod
    def tearDownClass(cls):
        cls.driver.quit()